package com.wnhz.work.jy.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import com.wnhz.work.jy.R;
import com.wnhz.work.jy.bean.OrderBean;
import com.wnhz.work.jy.bean.ShoppingBean;

import org.xutils.image.ImageOptions;
import org.xutils.x;

import java.util.List;

/**
 * Created by Administrator on 2016/9/8 0008.
 */
public class OrderAdapter extends BaseAdapter {
    private Context context;
    private List<ShoppingBean> orderList;
    public OrderAdapter(Context context, List<ShoppingBean> orderList) {
        this.context = context;
        this.orderList = orderList;
    }

    @Override
    public int getCount() {
        return orderList.size();
    }

    @Override
    public Object getItem(int position) {
        return orderList.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        OrderViewHolder viewHolder = new OrderViewHolder();
        if (convertView == null) {
            convertView = LayoutInflater.from(context).inflate(R.layout.order_item, null);
            viewHolder.iv_img = (ImageView) convertView.findViewById(R.id.iv_img);
            viewHolder.tv_title = (TextView) convertView.findViewById(R.id.tv_title);
            viewHolder.tv_money = (TextView) convertView.findViewById(R.id.tv_money);
            viewHolder.tv_numbers = (TextView) convertView.findViewById(R.id.tv_numbers);

            convertView.setTag(viewHolder);
        } else {
            viewHolder = (OrderViewHolder) convertView.getTag();
        }

        x.image().bind(viewHolder.iv_img,orderList.get(position).getGoodImg());
        viewHolder.tv_title.setText(orderList.get(position).getGoodName());
        viewHolder.tv_money.setText("¥" + orderList.get(position).getGoodPrice());
        viewHolder.tv_numbers.setText("x"+orderList.get(position).getGoodNumber());
        return convertView;
    }

    class OrderViewHolder {
        ImageView iv_img;
        TextView tv_title;
        TextView tv_color;
        TextView tv_money;
        TextView tv_numbers;
    }
}
